<template>
    <div>
        跳转带来的参数:{{name}}
        <button @click="go">有历史记录并且带参数的</button>
        <button @click="goNoHistoery">没有历史记录</button>

        <input v-model="msg"/>
    </div>
</template>

<script>
    export default {
        name: "routerTest",
        data() {
            return {name: null, meg: null,path:'/routerTest2'}
        },
        created() {
            let {name = ''} = this.$route.query;
            this.name = name;
        },
        methods: {
            go() {
                //能直接跳转
                this.$router.push({path: this.path, query: {name: '张三'}});
            },
            goNoHistoery() {
                this.$router.replace(this.path);
            }
        }
    }
</script>

<style scoped>

</style>
